<?php

namespace app\models\user\gc;

use Yii;

/**
 * This is the model class for table "{{%users_baseinfo_gc}}".
 *
 * @property int $id 用户id和users表id对应
 * @property int|null $isbase 是否填写基本信息
 * @property int|null $iszhengjian 证件上传
 * @property int|null $isgongchangchanpin 工厂产品
 * @property int|null $isgongchangshebei 工厂设备
 * @property int|null $ischanpinchanneng 产品产能
 * @property int|null $iszhiliangyaoqiu 质量要求
 * @property int|null $isgongchanghuanjing 工厂环境
 */
class UsersBaseinfoGc extends \app\models\BaseUserModel
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%users_baseinfo_gc}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['isbase', 'iszhengjian', 'isgongchangchanpin', 'isgongchangshebei', 'ischanpinchanneng', 'iszhiliangyaoqiu', 'isgongchanghuanjing'], 'integer'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'isbase' => '基本信息',
            'iszhengjian' => '证件上传',
            'isgongchangchanpin' => '工厂产品',
            'isgongchangshebei' => '工厂设备',
            'ischanpinchanneng' => '产品产能',
            'iszhiliangyaoqiu' => '质量要求',
            'isgongchanghuanjing' => '工厂环境',
        ];
    }

    public static function setIS($Field, $uid=null)
    {
        if($uid===null){
            $uid=Yii::$app->user->getId();
        }
        $one = self::find()->where([
            'id' => $uid
        ])->one();
        if (!$one) {
            $one = new self;
            $one->id = $uid;
        }
        $one[$Field] = 1;
        $one->save();
    }
}
